package com.codedancer.campus.manager.api.lostFoundItemComment;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;

import com.codedancer.campus.common.anno.InterfacePermission;
import com.codedancer.campus.common.core.BaseApi;
import com.codedancer.campus.common.response.ApiResponse;
import com.codedancer.campus.manager.api.lostFoundItemComment.ro.LostFoundCommentPageSearchRo;
import com.codedancer.campus.manager.service.ILostFoundItemCommentService;
import com.codedancer.campus.manager.service.bo.lostFoundItemComment.LostFoundCommentPageSearchBo;
import com.codedancer.campus.manager.service.vo.lostFoundItemComment.LostFoundItemCommentVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/lost-found-item-comment")
@CrossOrigin(methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.DELETE,
    RequestMethod.PUT}, maxAge = 3600)
@Api(value = "失物招领物品评论Api", description = "失物招领物品评论Api", tags = "失物招领物品评论Api")
public class LostCFoundItemCommentApi extends BaseApi {

    @Autowired
    private ILostFoundItemCommentService lostFoundItemCommentService;

    @GetMapping("/page/{lostFoundItemUuid}")
    @ApiOperation("分页查询某个物品的评论")
    @InterfacePermission(encodes = {"superAdmin","lostFoundItemAdmin"})
    public ApiResponse<IPage<LostFoundItemCommentVo>> page(
        @PathVariable(value = "lostFoundItemUuid", required = true) @ApiParam(value = "物品uuid", required = true) String lostFoundItemUuid,
        @ApiParam(value = "物品分页搜索Ro", required = false) LostFoundCommentPageSearchRo lostFoundCommentPageSearchRo) {
        LostFoundCommentPageSearchBo lostFoundCommentPageSearchBo = BeanUtil.copyProperties(
            lostFoundCommentPageSearchRo, LostFoundCommentPageSearchBo.class);
        lostFoundCommentPageSearchBo.setLostFoundItemUuid(lostFoundItemUuid);
        return success(lostFoundItemCommentService.page(lostFoundCommentPageSearchBo));
    }
}
